import java.util.Date
import org.apache.commons.codec.digest.DigestUtils as DU

class BootStrap {

     def init = { servletContext ->
        def pass = DU.md5Hex("admin")
        User user = new User(username:"admin",userRealName:"admin",passwd:pass,enabled:true,email:"bcg@certi.org.br")
	user.save()

        new Role(people:user,description:"Superuser",authority:"ROLE_ADMIN").save()

	new Requestmap(url:"/home/**",configAttribute:"ROLE_ANONYMOUS,ROLE_ADMIN").save()
	new Requestmap(url:"/book/list",configAttribute:"ROLE_ANONYMOUS,ROLE_ADMIN").save()
 	new Requestmap(url:"/bookitem/list",configAttribute:"ROLE_ANONYMOUS,ROLE_ADMIN").save()
        new Requestmap(url:"/rent/list",configAttribute:"ROLE_ANONYMOUS,ROLE_ADMIN").save()
        new Requestmap(url:"/book/**",configAttribute:"ROLE_ADMIN").save()
        new Requestmap(url:"/bookitem/**",configAttribute:"ROLE_ADMIN").save()
        new Requestmap(url:"/rent/**",configAttribute:"ROLE_ADMIN").save()
        new Requestmap(url:"/user/**",configAttribute:"ROLE_ADMIN").save()
    	new Requestmap(url:"/role/**",configAttribute:"ROLE_ADMIN").save()
        new Requestmap(url:"/requestmap/**",configAttribute:"ROLE_ADMIN").save()
        new Requestmap(url:"/admin/**",configAttribute:"ROLE_ADMIN").save()

     }
     def destroy = {
     }
} 
